package define
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	
	import mx.controls.DataGrid;
	import mx.controls.listClasses.IListItemRenderer;
	
	[Style(name="rollOverAlpha", type="Number", inherit="no")]
	[Style(name="selectionAlpha", type="Number", inherit="no")]
	public class MyDataGrid extends mx.controls.DataGrid
	{
		public function MyDataGrid()
		{
			super();
		}
		override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void
		{
			// get style -- is this the right place?
			var alpha:Number = this.getStyle("rollOverAlpha");
			if (isNaN(alpha))
				alpha = 1.0;
			
			// no need to draw if alpha 0
			if (alpha <= 0)
				return;
			
			// draw -- this has been copied from superclass, and the alpha parameter added to beginFill()
			var g:Graphics = Sprite(indicator).graphics;
			g.clear();
			g.beginFill(color, alpha);
			g.drawRect(0, 0, this.width, height);
			g.endFill();
			
			indicator.x = x;
			indicator.y = y;
		}
		
		override protected function drawSelectionIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void
		{
			// get style -- is this the right place?
			var alpha:Number = this.getStyle("selectionAlpha");
			if (isNaN(alpha))
				alpha = 1.0;
			
			// no need to draw if alpha 0
			if (alpha <= 0)
				return;
			
			// draw -- this has been copied from superclass, and the alpha parameter added to beginFill()
			var g:Graphics = Sprite(indicator).graphics;
			g.clear();
			g.beginFill(color, alpha);
			g.drawRect(0, 0, this.width, height);
			g.endFill();
			
			indicator.x = x;
			indicator.y = y;
		}
	}
}